package pers.xx.sbm.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import pers.xx.sbm.service.ReportDataService;
import pers.xx.sbm.vo.TotalSampleVo;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @author ：xiexing
 * @description：报告数据控制器
 * @date ：2021/12/10 17:36
 */
@Controller
@RequestMapping("/reportData")
public class ReportDataController {

    @Autowired
    private ReportDataService reportDataService;

    /**
     * 市级接口
     *
     * @return
     */
    @RequestMapping(value = "/getData", method = RequestMethod.GET)
    @ResponseBody
    public Map<String, Object> getData() {
        Map result = new HashMap<>();
        //查询不同角色样本总量
        String totalSample =reportDataService.queryRoleTotalSample();
        result.put("totalSample",totalSample);

        //样本总量在学段上的分布
        Map<String, ArrayList<Integer>> xdTotalSample = reportDataService.queryXdTotalSample();
        result.put("xdTotalSample",xdTotalSample);

        //样本在学段和区县上的分布
        String totalSamplePercentage = reportDataService.queryTotalSamplePercentage();
        result.put("totalSamplePercentage",totalSamplePercentage);

        //学生样本
        String studentTotalSamplePercentage = reportDataService.queryRoleXdTotalSamplePercentage("学生");
        result.put("studentTotalSamplePercentage",studentTotalSamplePercentage);
        List<TotalSampleVo> studentTotalSample = reportDataService.queryRoleXdTotalSample("学生");
        result.put("studentTotalSample",studentTotalSample);
        List<Object> studentAreaTotalSample = reportDataService.queryRoleAreaTotalSamplePercentage("学生");
        result.put("studentAreaTotalSample",studentAreaTotalSample);

        //家长样本
        String parentTotalSamplePercentage = reportDataService.queryRoleXdTotalSamplePercentage("家长");
        result.put("parentTotalSamplePercentage",parentTotalSamplePercentage);
        List<TotalSampleVo> parentTotalSample = reportDataService.queryRoleXdTotalSample("家长");
        result.put("parentTotalSample",parentTotalSample);
        List<Object> parentAreaTotalSample = reportDataService.queryRoleAreaTotalSamplePercentage("家长");
        result.put("parentAreaTotalSample",parentAreaTotalSample);

        //教师样本
        String teacherTotalSamplePercentage = reportDataService.queryRoleXdTotalSamplePercentage("教师");
        result.put("teacherTotalSamplePercentage",teacherTotalSamplePercentage);
        List<TotalSampleVo> teacherTotalSample = reportDataService.queryRoleXdTotalSample("教师");
        result.put("teacherTotalSample",teacherTotalSample);
        List<Object> teacherAreaTotalSample = reportDataService.queryRoleAreaTotalSamplePercentage("教师");
        result.put("teacherAreaTotalSample",teacherAreaTotalSample);

        //园长样本
        String yzTotalSamplePercentage = reportDataService.queryRoleXdTotalSamplePercentage("园长");
        result.put("yzTotalSamplePercentage",yzTotalSamplePercentage);
        List<Object> yzAreaTotalSample = reportDataService.queryRoleAreaTotalSamplePercentage("园长");
        result.put("yzAreaTotalSample",yzAreaTotalSample);

        //人大代表/政协委员样本
        String rddbTotalSamplePercentage = reportDataService.queryRoleXdTotalSamplePercentage("人大代表/政协委员");
        result.put("rddbTotalSamplePercentage",rddbTotalSamplePercentage);
        List<Object> rddbAreaTotalSample = reportDataService.queryRoleAreaTotalSamplePercentage("人大代表/政协委员");
        result.put("rddbAreaTotalSample",rddbAreaTotalSample);


        //总体调查结果
        String totalSatisfaction = reportDataService.queryTotalSatisfaction();
        result.put("totalSatisfaction",totalSatisfaction);

        //各区县满意率
        Map<String, List<Double>> areaSamplePercentage = reportDataService.queryAreaSamplePercentage();
        result.put("areaSamplePercentage",areaSamplePercentage);

        //各学段调查结果
        String xdSatisfaction = reportDataService.queryXdSatisfaction();
        result.put("xdSatisfaction",xdSatisfaction);

        //各学段满意率
        Map<String, List<Double>> xdSamplePercentage = reportDataService.queryXdSamplePercentage();
        result.put("xdSamplePercentage",xdSamplePercentage);

        //分人群学生
        String studentAreaSatisfaction = reportDataService.queryAreaSatisfactionByRole("学生");
        result.put("studentAreaSatisfaction",studentAreaSatisfaction);
        Map<String, List<Double>> studentAreaSatisfactionPercentage = reportDataService.queryAreaSatisfactionPercentageByRole("学生");
        result.put("studentAreaSatisfactionPercentage",studentAreaSatisfactionPercentage);

        //分人群教师
        String teacherAreaSatisfaction = reportDataService.queryAreaSatisfactionByRole("教师");
        result.put("teacherAreaSatisfaction",teacherAreaSatisfaction);
        Map<String, List<Double>> teacherAreaSatisfactionPercentage = reportDataService.queryAreaSatisfactionPercentageByRole("教师");
        result.put("teacherAreaSatisfactionPercentage",teacherAreaSatisfactionPercentage);

        //分人群家长
        String parentAreaSatisfaction = reportDataService.queryAreaSatisfactionByRole("家长");
        result.put("parentAreaSatisfaction",parentAreaSatisfaction);
        Map<String, List<Double>> parentAreaSatisfactionPercentage = reportDataService.queryAreaSatisfactionPercentageByRole("家长");
        result.put("parentAreaSatisfactionPercentage",parentAreaSatisfactionPercentage);

        //分人群园长
        String yzAreaSatisfaction = reportDataService.queryAreaSatisfactionByRole("园长");
        result.put("yzAreaSatisfaction",yzAreaSatisfaction);
        Map<String, List<Double>> yzAreaSatisfactionPercentage = reportDataService.queryAreaSatisfactionPercentageByRole("园长");
        result.put("yzAreaSatisfactionPercentage",yzAreaSatisfactionPercentage);

        //分人群人大代表/政协委员
        String rddbAreaSatisfaction = reportDataService.queryAreaSatisfactionByRole("人大代表/政协委员");
        result.put("rddbAreaSatisfaction",rddbAreaSatisfaction);
        Map<String, List<Double>> rddbAreaSatisfactionPercentage = reportDataService.queryAreaSatisfactionPercentageByRole("人大代表/政协委员");
        result.put("rddbAreaSatisfactionPercentage",rddbAreaSatisfactionPercentage);

        //高中综合满意情况

        //总体调查结果
        String gzTotalSatisfaction = reportDataService.queryTotalSatisfactionByXd("高中");
        result.put("gzTotalSatisfaction", gzTotalSatisfaction);
        Map<String, List<Double>> gzAreaSatisfactionPercentage = reportDataService.queryAreaSatisfactionPercentageByXdAndRole("高中","");
        result.put("gzAreaSatisfactionPercentage", gzAreaSatisfactionPercentage);

        //分人群（高中学生）
        String gzStudentTotalSatisfaction = reportDataService.queryTotalSatisfactionByXdAndRole("高中","学生");
        result.put("gzStudentTotalSatisfaction", gzStudentTotalSatisfaction);
        Map<String, List<Double>> gzStudentAreaSatisfactionPercentage = reportDataService.queryAreaSatisfactionPercentageByXdAndRole("高中","学生");
        result.put("gzStudentAreaSatisfactionPercentage", gzStudentAreaSatisfactionPercentage);

        //分人群（高中教师）
        String gzTeacherTotalSatisfaction = reportDataService.queryTotalSatisfactionByXdAndRole("高中","教师");
        result.put("gzTeacherTotalSatisfaction", gzTeacherTotalSatisfaction);
        Map<String, List<Double>> gzTeacherAreaSatisfactionPercentage = reportDataService.queryAreaSatisfactionPercentageByXdAndRole("高中","教师");
        result.put("gzTeacherAreaSatisfactionPercentage", gzTeacherAreaSatisfactionPercentage);

        //分人群（高中家长）
        String gzParentTotalSatisfaction = reportDataService.queryTotalSatisfactionByXdAndRole("高中","家长");
        result.put("gzParentTotalSatisfaction", gzParentTotalSatisfaction);
        Map<String, List<Double>> gzParentAreaSatisfactionPercentage = reportDataService.queryAreaSatisfactionPercentageByXdAndRole("高中","家长");
        result.put("gzParentAreaSatisfactionPercentage", gzParentAreaSatisfactionPercentage);

        //分项目（高中学生）
        String gzStudentProjectIndicators = reportDataService.queryProjectIndicatorsByXdAndRole("高中","学生");
        result.put("gzStudentProjectIndicators", gzStudentProjectIndicators);
        Map<String, ArrayList<Double>> gzStudentProjectIndicatorsList = reportDataService.queryIndexSatisfactionByXdAndRole("高中", "学生");
        result.put("gzStudentProjectIndicatorsList", gzStudentProjectIndicatorsList);

        //分项目（高中教师）
        String gzTeacherProjectIndicators = reportDataService.queryProjectIndicatorsByXdAndRole("高中","教师");
        result.put("gzTeacherProjectIndicators", gzTeacherProjectIndicators);
        Map<String, ArrayList<Double>> gzTeacherProjectIndicatorsList = reportDataService.queryIndexSatisfactionByXdAndRole("高中", "教师");
        result.put("gzTeacherProjectIndicatorsList", gzTeacherProjectIndicatorsList);

        //分项目（高中家长）
        String gzParentProjectIndicators = reportDataService.queryProjectIndicatorsByXdAndRole("高中","家长");
        result.put("gzParentProjectIndicators", gzParentProjectIndicators);
        Map<String, ArrayList<Double>> gzParentProjectIndicatorsList = reportDataService.queryIndexSatisfactionByXdAndRole("高中", "家长");
        result.put("gzParentProjectIndicatorsList", gzParentProjectIndicatorsList);



        //初中

        //总体调查结果
        String czTotalSatisfaction = reportDataService.queryTotalSatisfactionByXd("初中");
        result.put("czTotalSatisfaction", czTotalSatisfaction);
        Map<String, List<Double>> czAreaSatisfactionPercentage = reportDataService.queryAreaSatisfactionPercentageByXdAndRole("初中","");
        result.put("czAreaSatisfactionPercentage", czAreaSatisfactionPercentage);

        //分人群（初中学生）
        String czStudentTotalSatisfaction = reportDataService.queryTotalSatisfactionByXdAndRole("初中","学生");
        result.put("czStudentTotalSatisfaction", czStudentTotalSatisfaction);
        Map<String, List<Double>> czStudentAreaSatisfactionPercentage = reportDataService.queryAreaSatisfactionPercentageByXdAndRole("初中","学生");
        result.put("czStudentAreaSatisfactionPercentage", czStudentAreaSatisfactionPercentage);

        //分人群（初中教师）
        String czTeacherTotalSatisfaction = reportDataService.queryTotalSatisfactionByXdAndRole("初中","教师");
        result.put("czTeacherTotalSatisfaction", czTeacherTotalSatisfaction);
        Map<String, List<Double>> czTeacherAreaSatisfactionPercentage = reportDataService.queryAreaSatisfactionPercentageByXdAndRole("初中","教师");
        result.put("czTeacherAreaSatisfactionPercentage", czTeacherAreaSatisfactionPercentage);

        //分人群（初中家长）
        String czParentTotalSatisfaction = reportDataService.queryTotalSatisfactionByXdAndRole("初中","家长");
        result.put("czParentTotalSatisfaction", czParentTotalSatisfaction);
        Map<String, List<Double>> czParentAreaSatisfactionPercentage = reportDataService.queryAreaSatisfactionPercentageByXdAndRole("初中","家长");
        result.put("czParentAreaSatisfactionPercentage", czParentAreaSatisfactionPercentage);

        //分项目（初中学生）
        String czStudentProjectIndicators = reportDataService.queryProjectIndicatorsByXdAndRole("初中","学生");
        result.put("czStudentProjectIndicators", czStudentProjectIndicators);
        Map<String, ArrayList<Double>> czStudentProjectIndicatorsList = reportDataService.queryIndexSatisfactionByXdAndRole("初中", "学生");
        result.put("czStudentProjectIndicatorsList", czStudentProjectIndicatorsList);

        //分项目（初中教师）
        String czTeacherProjectIndicators = reportDataService.queryProjectIndicatorsByXdAndRole("初中","教师");
        result.put("czTeacherProjectIndicators", czTeacherProjectIndicators);
        Map<String, ArrayList<Double>> czTeacherProjectIndicatorsList = reportDataService.queryIndexSatisfactionByXdAndRole("初中", "教师");
        result.put("czTeacherProjectIndicatorsList", czTeacherProjectIndicatorsList);

        //分项目（初中家长）
        String czParentProjectIndicators = reportDataService.queryProjectIndicatorsByXdAndRole("初中","家长");
        result.put("czParentProjectIndicators", czParentProjectIndicators);
        Map<String, ArrayList<Double>> czParentProjectIndicatorsList = reportDataService.queryIndexSatisfactionByXdAndRole("初中", "家长");
        result.put("czParentProjectIndicatorsList", czParentProjectIndicatorsList);




        //小学

        //总体调查结果
        String xxTotalSatisfaction = reportDataService.queryTotalSatisfactionByXd("小学");
        result.put("xxTotalSatisfaction", xxTotalSatisfaction);
        Map<String, List<Double>> xxAreaSatisfactionPercentage = reportDataService.queryAreaSatisfactionPercentageByXdAndRole("小学","");
        result.put("xxAreaSatisfactionPercentage", xxAreaSatisfactionPercentage);

        //分人群（小学学生）
        String xxStudentTotalSatisfaction = reportDataService.queryTotalSatisfactionByXdAndRole("小学","学生");
        result.put("xxStudentTotalSatisfaction", xxStudentTotalSatisfaction);
        Map<String, List<Double>> xxStudentAreaSatisfactionPercentage = reportDataService.queryAreaSatisfactionPercentageByXdAndRole("小学","学生");
        result.put("xxStudentAreaSatisfactionPercentage", xxStudentAreaSatisfactionPercentage);

        //分人群（小学教师）
        String xxTeacherTotalSatisfaction = reportDataService.queryTotalSatisfactionByXdAndRole("小学","教师");
        result.put("xxTeacherTotalSatisfaction", xxTeacherTotalSatisfaction);
        Map<String, List<Double>> xxTeacherAreaSatisfactionPercentage = reportDataService.queryAreaSatisfactionPercentageByXdAndRole("小学","教师");
        result.put("xxTeacherAreaSatisfactionPercentage", xxTeacherAreaSatisfactionPercentage);

        //分人群（小学家长）
        String xxParentTotalSatisfaction = reportDataService.queryTotalSatisfactionByXdAndRole("小学","家长");
        result.put("xxParentTotalSatisfaction", xxParentTotalSatisfaction);
        Map<String, List<Double>> xxParentAreaSatisfactionPercentage = reportDataService.queryAreaSatisfactionPercentageByXdAndRole("小学","家长");
        result.put("xxParentAreaSatisfactionPercentage", xxParentAreaSatisfactionPercentage);

        //分项目（小学学生）
        String xxStudentProjectIndicators = reportDataService.queryProjectIndicatorsByXdAndRole("小学","学生");
        result.put("xxStudentProjectIndicators", xxStudentProjectIndicators);
        Map<String, ArrayList<Double>> xxStudentProjectIndicatorsList = reportDataService.queryIndexSatisfactionByXdAndRole("小学", "学生");
        result.put("xxStudentProjectIndicatorsList", xxStudentProjectIndicatorsList);

        //分项目（小学教师）
        String xxTeacherProjectIndicators = reportDataService.queryProjectIndicatorsByXdAndRole("小学","教师");
        result.put("xxTeacherProjectIndicators", xxTeacherProjectIndicators);
        Map<String, ArrayList<Double>> xxTeacherProjectIndicatorsList = reportDataService.queryIndexSatisfactionByXdAndRole("小学", "教师");
        result.put("xxTeacherProjectIndicatorsList", xxTeacherProjectIndicatorsList);

        //分项目（小学家长）
        String xxParentProjectIndicators = reportDataService.queryProjectIndicatorsByXdAndRole("小学","家长");
        result.put("xxParentProjectIndicators", xxParentProjectIndicators);
        Map<String, ArrayList<Double>> xxParentProjectIndicatorsList = reportDataService.queryIndexSatisfactionByXdAndRole("小学", "家长");
        result.put("xxParentProjectIndicatorsList", xxParentProjectIndicatorsList);





        //幼儿园

        //总体调查结果
        String yeyTotalSatisfaction = reportDataService.queryTotalSatisfactionByXd("幼儿园");
        result.put("yeyTotalSatisfaction", yeyTotalSatisfaction);
        Map<String, List<Double>> yeyAreaSatisfactionPercentage = reportDataService.queryAreaSatisfactionPercentageByXdAndRole("幼儿园","");
        result.put("yeyAreaSatisfactionPercentage", yeyAreaSatisfactionPercentage);

        //分人群（幼儿园教师）
        String yeyTeacherTotalSatisfaction = reportDataService.queryTotalSatisfactionByXdAndRole("幼儿园","教师");
        result.put("yeyTeacherTotalSatisfaction", yeyTeacherTotalSatisfaction);
        Map<String, List<Double>> yeyTeacherAreaSatisfactionPercentage = reportDataService.queryAreaSatisfactionPercentageByXdAndRole("幼儿园","教师");
        result.put("yeyTeacherAreaSatisfactionPercentage", yeyTeacherAreaSatisfactionPercentage);

        //分人群（幼儿园家长）
        String yeyParentTotalSatisfaction = reportDataService.queryTotalSatisfactionByXdAndRole("幼儿园","家长");
        result.put("yeyParentTotalSatisfaction", yeyParentTotalSatisfaction);
        Map<String, List<Double>> yeyParentAreaSatisfactionPercentage = reportDataService.queryAreaSatisfactionPercentageByXdAndRole("幼儿园","家长");
        result.put("yeyParentAreaSatisfactionPercentage", yeyParentAreaSatisfactionPercentage);

        //分人群（幼儿园园长）
        String yeyYzTotalSatisfaction = reportDataService.queryTotalSatisfactionByXdAndRole("幼儿园","园长");
        result.put("yeyYzTotalSatisfaction", yeyYzTotalSatisfaction);
        Map<String, List<Double>> yeyYzAreaSatisfactionPercentage = reportDataService.queryAreaSatisfactionPercentageByXdAndRole("幼儿园","园长");
        result.put("yeyYzAreaSatisfactionPercentage", yeyYzAreaSatisfactionPercentage);

        //分人群（幼儿园人大代表/政协委员）
        String yeyRddbTotalSatisfaction = reportDataService.queryTotalSatisfactionByXdAndRole("幼儿园","人大代表/政协委员");
        result.put("yeyRddbTotalSatisfaction", yeyRddbTotalSatisfaction);
        Map<String, List<Double>> yeyRddbAreaSatisfactionPercentage = reportDataService.queryAreaSatisfactionPercentageByXdAndRole("幼儿园","人大代表/政协委员");
        result.put("yeyRddbAreaSatisfactionPercentage", yeyRddbAreaSatisfactionPercentage);



        //分项目（幼儿园教师）
        String yeyTeacherProjectIndicators = reportDataService.queryProjectIndicatorsByXdAndRole("幼儿园","教师");
        result.put("yeyTeacherProjectIndicators", yeyTeacherProjectIndicators);
        Map<String, ArrayList<Double>> yeyTeacherProjectIndicatorsList = reportDataService.queryIndexSatisfactionByXdAndRole("幼儿园", "教师");
        result.put("yeyTeacherProjectIndicatorsList", yeyTeacherProjectIndicatorsList);

        //分项目（幼儿园家长）
        String yeyParentProjectIndicators = reportDataService.queryProjectIndicatorsByXdAndRole("幼儿园","家长");
        result.put("yeyParentProjectIndicators", yeyParentProjectIndicators);
        Map<String, ArrayList<Double>> yeyParentProjectIndicatorsList = reportDataService.queryIndexSatisfactionByXdAndRole("幼儿园", "家长");
        result.put("yeyParentProjectIndicatorsList", yeyParentProjectIndicatorsList);

        //分项目（幼儿园园长）
        String yeyYzProjectIndicators = reportDataService.queryProjectIndicatorsByXdAndRole("幼儿园","园长");
        result.put("yeyYzProjectIndicators", yeyYzProjectIndicators);
        Map<String, ArrayList<Double>> yeyYzProjectIndicatorsList = reportDataService.queryIndexSatisfactionByXdAndRole("幼儿园", "园长");
        result.put("yeyYzProjectIndicatorsList", yeyYzProjectIndicatorsList);

        //分项目（幼儿园人大代表/政协委员）
        String yeyRddbProjectIndicators = reportDataService.queryProjectIndicatorsByXdAndRole("幼儿园","人大代表/政协委员");
        result.put("yeyRddbProjectIndicators", yeyRddbProjectIndicators);
        Map<String, ArrayList<Double>> yeyRddbProjectIndicatorsList = reportDataService.queryIndexSatisfactionByXdAndRole("幼儿园", "人大代表/政协委员");
        result.put("yeyRddbProjectIndicatorsList", yeyRddbProjectIndicatorsList);

        return result;
    }
}
